# -*- coding: utf-8 -*-
#===================================================
# @Time : 2021/3/8 15:56                           
# @Author : weni09                                  
# @File : test.py
#===================================================
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.permissions import IsAuthenticated

class TestView(APIView):
    permission_classes = (IsAuthenticated,)
    def get(self, request):
        print('authenticators:', request.authenticators)
        print('successful_authenticator:', request.successful_authenticator)
        print('authenticate: ', request.successful_authenticator.authenticate(request))
        print('authenticate_header: ', request.successful_authenticator.authenticate_header(request))
        print('get_header: ', request.successful_authenticator.get_header(request))
        print('get_raw_token: ', request.successful_authenticator.get_raw_token(request.successful_authenticator.get_header(request)))
        print('get_validated_token: ', request.successful_authenticator.get_validated_token(request.successful_authenticator.get_raw_token(request.successful_authenticator.get_header(request))))
        print('get_user: ', request.successful_authenticator.get_user(request.successful_authenticator.get_validated_token(request.successful_authenticator.get_raw_token(request.successful_authenticator.get_header(request)))))
        print('www_authenticate_realm: ', request.successful_authenticator.www_authenticate_realm)
        return Response("OK")



# import base64
#
# print(base64.b64decode('eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjE1MjE3ODE0LCJqdGkiOiI1NTUyZDBjMzZkYjM0MjM3OTVkYmZlNTZhMmRhZmIwYiIsInVzZXJfaWQiOjJ9').decode())
#
# import datetime
# timeStamp = 1615217814
# dateArray = datetime.datetime.fromtimestamp(timeStamp)
# otherStyleTime = dateArray.strftime("%Y-%m-%d %H:%M:%S")
# print(otherStyleTime)   # 2013--10--10 23:40:00